from django.db import models
from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField
import uuid

# Create your models here.

class CommonModel(models.Model):
    author_id = models.UUIDField(primary_key=False, default=uuid.uuid4, editable=False)
    author_username = models.CharField(max_length=50)
    createDate = models.DateTimeField(auto_now=False, auto_now_add=True)
    updateDate = models.DateTimeField(auto_now=True, auto_now_add=False)

    class Meta:
        abstract = True

'''
博文
'''
class Article(CommonModel):
    article_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    title = models.CharField(max_length=50)
    content = RichTextUploadingField()

'''
评论
'''
class Comments(CommonModel):
    pub_author_id = models.CharField(max_length=50)
    ref_article = models.ForeignKey(Article,on_delete=models.CASCADE)
    comment_text = models.TextField(max_length=300)
    comment_field = RichTextField()

'''
图片
'''
class Img(CommonModel):
    ref_article = models.ForeignKey(Article,on_delete=models.CASCADE)
    src = models.CharField(max_length=50)
    img_no = models.CharField(max_length=50)
    img_title = models.CharField(max_length=50)
    img_text = models.TextField(max_length=300)

'''
用户注册 邮箱与验证码对应表
'''
class UserSignTempVerifyCode(models.Model):
    verification_code = models.CharField(max_length=6) #随机数
    sign_email = models.EmailField(max_length=254,) #注册邮箱